package com.zs.diveinspringboot.servlet

import javax.servlet.annotation.WebServlet
import javax.servlet.http.HttpServlet
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

/**
 *
 * @description
 * @author madison
 * @date 2021/6/3 12:13
 *
 */
@WebServlet(urlPatterns = ["/my/servlet"], asyncSupported = true)
class MyServlet : HttpServlet() {
    override fun doGet(req: HttpServletRequest?, resp: HttpServletResponse?) {
        val asyncContext = req?.startAsync()
        asyncContext?.start { resp?.writer?.println("Hello,World") }
        // 触发完成
        asyncContext?.complete()
    }

    override fun doPost(req: HttpServletRequest?, resp: HttpServletResponse?) {
        doGet(req, resp)
    }
}